package com.micro.school.system.api.factory;

import com.micro.school.common.core.domain.R;
import com.micro.school.system.api.RemoteOrderService;
import com.micro.school.system.api.domain.vo.*;
import com.micro.school.system.api.domain.vo.order.PayStudentFeeVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Component
public class RemoteOrderFallbackFactory implements FallbackFactory<RemoteOrderService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteOrderFallbackFactory.class);

    @Override
    public RemoteOrderService create(Throwable cause) {
        log.error("订单服务调用失败:{}", cause.getMessage());
        return new RemoteOrderService() {
            @Override
            public R<PayStudentFeeVos> queryStudentFee(PayStudentFeeVos payStudentFeeVos) {
                return R.fail("获取学生费用信息失败:" + cause.getMessage());
            }

            @Override
            public R<Map<String, Map<String, Object>>> queryStudentFeeItem(PayStudentFeeVos payStudentFeeVos) {
                return R.fail("获取学生费用项信息失败:" + cause.getMessage());
            }

            @Override
            public R<List<PayStudentFeeItemVos>> queryStudentFeeItemDetails(PayStudentFeeVos payStudentFeeVos) {
                return R.fail("获取学生费用项详情失败:" + cause.getMessage());
            }

            @Override
            public R<List<PayStudentPrepaymentVos>> getStudentPrepaymentVos(PayStudentPrepaymentVos payStudentPrepaymentVos) {
                return R.fail("获取学生预缴费费用项详情失败:" + cause.getMessage());
            }

            @Override
            public R<List<PayStudentPrepaymentVos>> getStudentPrepaymentNoVos(PayStudentPrepaymentVos payStudentPrepaymentVos) {
                return null;
            }

            @Override
            public void updateCollectionStatus(PayStudentPrepaymentVos payStudentPrepayment1) {
                log.error("更新归集状态失败:id={}", payStudentPrepayment1, cause);
            }

            @Override
            public void insertPayStudentFeePayment(PayStudentFeePaymentVos payStudentFeePaymentVos) {
                log.error("插入支付单失败:{}", payStudentFeePaymentVos, cause);
            }

            @Override
            public PayFeeItemConfigVos selectMerchantByConfigId(PayFeeItemConfigVos payFeeItemConfigVos) {
                log.error("根据配置ID查询商户失败:id={}", payFeeItemConfigVos, cause);
                return null;
            }

            @Override
            public void insertPayStudentFeePaymentDetailVos(PayStudentFeePaymentDetailVos detail) {
                log.error("插入支付单详情失败:{}", detail, cause);
            }

            @Override
            public void updateStudentPrepayment(PayStudentPrepaymentVos prepayment) {
                log.error("更新学生预缴费记录失败:{}", prepayment, cause);
            }
            @Override
            public R<List<PayStudentFeeVo>> getStudentBillH5(@PathVariable("studentId") Integer studentId){
                log.error("H5查询账单失败studentId:{}", studentId, cause);
                return null;
            }
            @Override
            public R<List<PayStudentFeeVo>> getStudentPaymentInfo(@PathVariable("studentId") Integer studentId){
                log.error("H5查询支付失败studentId:{}", studentId, cause);
                return null;
            }

            @Override
            public R<List<StudentPayVos>> selectStudentFeeByStudentId(Long studentId, Long feeYearId) {
                return null;
            }

            @Override
            public Map<String, Object> updateAllPayStudentFeePayment(String payNumber, Long status) {
                return Map.of();
            }

            @Override
            public R<PayStudentFeePaymentVos> updateStudentFeePayment(PayStudentFeePaymentVos payStudentFeePaymentVos) {
                return null;
            }

            @Override
            public void updateStudentFee(List<PayStudentFeePaymentDetailVos> payStudentFeePaymentVosDetails) {
                log.error("插入支付单详情失败:{}", payStudentFeePaymentVosDetails, cause);
            }

            @Override
            public PayStudentFeeVos queryStudentFeeByDetail(Long studentFeeId) {
                return null;
            }

            @Override
            public BigDecimal sumStudentFee(Long studentFeeId) {
                return null;
            }

            @Override
            public void updateStudentFeeTotalMoney(PayStudentFeeVos payStudentFeeVos1) {
                log.error("插入支付单详情失败:{}", payStudentFeeVos1, cause);
            }

            @Override
            public void updateAllOrderCollegeName(String collegeName, Long collegeId) {
                log.error("修改学院名称失败:{}", collegeName, cause);
            }

            @Override
            public void updateAllCollegeMajor(String majorName, Long id) {

            }

            @Override
            public void updateAllCollegeModel(String modelName, Long id) {

            }

            @Override
            public void updateAllCampusName(String campusName, Long id) {

            }

            @Override
            public void updateAllFeeYear(String feeYear, Long id) {

            }
        };
    }
}
